<!DOCTYPE html>
<html>
<head lang="en">
    <meta charset="UTF-8">
    <title>模态框</title>
    <link href="../../../css/bootstrap.min.css" rel="stylesheet">
</head>
<body>
    <button type="button" class="btn btn-primary btn-lg" data-toggle="modal"  data-target="#myModal" data-whatever="@ime">
        点击出现
    </button>
    <div class="modal fade bs-example-modal-sm"  id="myModal" role="dialog" aria-label="myModalLabel" aria-hidden="true">
        <div class="modal-dialog modal-sm">
            <div class="modal-content">
                <div class="modal-header">
                    <button type="button"class="close"data-dismiss="modal" aria-label="Close">
                        <span aria-hidden="true">&times;</span>
                    </button>
                    <h4 class="modal-title">Modal title</h4>
                </div>
                <div class="modal-body">
                    <form>
                        <div class="form-group">
                            <label class="control-label">usename</label>
                            <input type="text" class="form-control">
                        </div>
                        <div class="form-group">
                            <label class="control-label">password</label>
                            <input type="password" class="form-control">
                        </div>
                    </form>
                </div>
                <div class="modal-footer">
                    <button type="button"class="btn btn-default" data-dismiss="modal">
                        Close
                    </button>
                    <button type="button"class="btn btn-primary" >
                        保存
                    </button>
                </div>
            </div>
        </div>
    </div>
    <script src="../../../js/jquery-2.1.1.js"></script>
    <script src="../../../js/bootstrap.js"></script>
    <script>
        $("#myModal").on("show.bs.modal",function(e){
            var button=$(e.relatedTarget);
            var recipient=button.data("whatever");
            var modal=$(this);
            modal.find(".modal-title").text("Hello"+recipient);
            modal.find(".modal-body input").val(recipient);
        })
    </script>
</body>
</html>